﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:SQLServerCompanion;assembly="
                    xmlns:ctl="clr-namespace:SQLServerCompanion.Controls;assembly="
                    >

    <!-- Special TabControl that keeps all items in memory but changes Visibility, rather create
         entire VisualTree for SelectedItem from Stratch which if using MefedMVVM would mean a new
         View would be created with a new ViewModel, which means loss of state.  -->

    <Style x:Key="CloseableTabItemButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" 
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Border SnapsToDevicePixels="true" x:Name="Chrome" 
                                Background="Transparent" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="2" Opacity="0" />
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                HorizontalAlignment="{TemplateBinding 
                                HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" 
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                RecognizesAccessKey="True"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Opacity" TargetName="Chrome" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Opacity" TargetName="Chrome" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="Chartreuse"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    
    <Style x:Key="TabControlStyleHorizontalTabs" TargetType="{x:Type ctl:TabControlEx}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
        <Setter Property="Background" Value="White"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctl:TabControlEx}">
                    <DockPanel Background="{StaticResource horizontalTabHeaderBackground}">
                        <TabPanel x:Name="tabpanel" Margin="0,5,0,0"
                                      Visibility="Visible"
                                      DockPanel.Dock="Top"
                                      KeyboardNavigation.TabIndex="1"
                                      IsItemsHost="True" />
                        <Border  CornerRadius="2,0,0,2"
                                 Margin="0,5,0,5"
                                 Background="{TemplateBinding Background}">
                            <Grid DockPanel.Dock="Bottom" Margin="5,0,0,0"
                              Background="{TemplateBinding Background}"
                              x:Name="PART_ItemsHolder" />
                        </Border>
                    </DockPanel>
                    <!-- no content presenter -->
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" 
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--This is the style for the horizontal tabs for the main screen area.-->
    <Style x:Key="TabItemStyleHorizontalTabs" TargetType="{x:Type TabItem}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Foreground" Value="Yellow"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid SnapsToDevicePixels="true">
                        <Border x:Name="Bd" BorderThickness="0" CornerRadius="4">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="2"/>
                                </Grid.RowDefinitions>

                                <Grid Grid.Row="0">

                                    <Grid  x:Name="grid" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                                    
                                    <StackPanel Orientation="Horizontal" Margin="2" >

                                        
                                        <Image Source="{Binding ImagePath}" Width="16" Height="16" Margin="2,0,2,0" 
										   Visibility="{Binding HasImage, 
                                                Converter={StaticResource boolToVisConv}, 
                                                ConverterParameter=True}" VerticalAlignment="Center"/>

                                        <Label x:Name="lbl" Margin="2,0,2,0" 
                                            FontSize="12"
                                            FontWeight="Bold"
                                            Content="{Binding Path=DisplayText}" 
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Center" />

                                        <Button x:Name="PART_Close" HorizontalAlignment="Left" Margin="2,0,2,0" 
                                            VerticalAlignment="Center" Width="16" Height="16" 
                                            Command="{Binding Path=CloseWorkSpaceCommand}"   
                                            Visibility="{Binding IsCloseable, 
                                                Converter={StaticResource boolToVisConv}, 
                                                ConverterParameter=True}"
                                            Focusable="False"
                                            Style="{DynamicResource CloseableTabItemButtonStyle}" 
                                            ToolTip="Close Tab">
                                            <Path x:Name="Path" Stretch="Fill" StrokeThickness="0.5" 
                                              Stroke="{DynamicResource closeTabCrossStroke}" Fill="Black" 
                                              Data="F1 M 2.28484e-007,1.33331L 1.33333,0L 4.00001,2.66669L 6.66667,6.10352e-005L 8,1.33331L 5.33334,4L 8,6.66669L 6.66667,8L 4,5.33331L 1.33333,8L 1.086e-007,6.66669L 2.66667,4L 2.28484e-007,1.33331 Z " 
                                              HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                                        </Button>

                                    </StackPanel>

                                    <Image x:Name="imgSelectedImage" Visibility="Hidden" Height="16" Width="16." Source="/Images/circle-teal-24-ns.png"
											VerticalAlignment="Center" 
											HorizontalAlignment="Left"
                                            Margin="2"/>
                                </Grid>

                                <Rectangle x:Name="rectShine" Grid.Row="1" Opacity="0.5" Fill="#ff656565" StrokeThickness="0" HorizontalAlignment="Stretch"
										VerticalAlignment="Stretch" Height="3" />

                            </Grid>
                        </Border>



                    </Grid>
                    <ControlTemplate.Triggers>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource selectedBrush}"/>
                            <Setter Property="Background" TargetName="grid" Value="{StaticResource selectedGradientGlow}"/>
                            <!--<Setter Property="Opacity" TargetName="lblArrow" Value="1"/>-->
                            <Setter Property="Visibility" TargetName="imgSelectedImage" Value="Visible"/>
                            <Setter Property="Height" TargetName="rectShine" Value="2"/>


                        </MultiTrigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="false"/>
                                <Condition Property="IsMouseOver" Value="true"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <!--<Setter Property="Background" TargetName="Bd" Value="{StaticResource nonSelectedBrush}"/>-->
                            <Setter Property="Background" TargetName="Bd" Value="White"/>
                            <Setter Property="Background" TargetName="grid" Value="Transparent"/>
                            <Setter Property="Visibility" TargetName="imgSelectedImage" Value="Hidden"/>
                            <Setter Property="Height" TargetName="rectShine" Value="2"/>
                        </MultiTrigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="false"/>
                                <Condition Property="IsMouseOver" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Height" TargetName="rectShine" Value="0"/>
                            <Setter Property="Foreground" TargetName="lbl" Value="White"/>
                            <Setter Property="Fill" TargetName="Path" Value="White"/>

                        </MultiTrigger>

                        <Trigger Property="TabStripPlacement" Value="Right">
                             <Setter Property="HorizontalAlignment" TargetName="imgSelectedImage" Value="Left"/>
                        </Trigger>



                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

</ResourceDictionary>